From 7aa5afeb6c7d831bce239dbc8eab61812e233822 Mon Sep 17 00:00:00 2001 From: "cl349@firebug.cl.cam.ac.uk" Date: Wed, 27 Jul 2005 17:17:09 +0000 Subject: [PATCH] Always pass around the store machine frame number instead of the linear address. Also cleanup IOCTL_PRIVCMD_INITDOMAIN_STORE. Signed-off-by: Rusty Russel Signed-off-by: Christian Limpach --- linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c | 14 ++++++++------ .../drivers/xen/xenbus/xenbus_comms.c | 7 ++++--- .../drivers/xen/xenbus/xenbus_xs.c | 2 +- tools/libxc/xc_linux_build.c | 7 +++---- xen/include/public/xen.h | 2 +- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c index 50c8de3eae..e7f6ff5fcf 100644 --- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c +++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c @@ -200,27 +200,29 @@ static int privcmd_ioctl(struct inode *inode, struct file *file, case IOCTL_PRIVCMD_INITDOMAIN_STORE: { extern int do_xenbus_probe(void*); + unsigned long page; if (xen_start_info.store_evtchn != 0) { - ret = -EINVAL; + ret = xen_start_info.store_mfn; break; } /* Allocate page. */ - xen_start_info.store_page = get_zeroed_page(GFP_KERNEL); - if (!xen_start_info.store_page) { + page = get_zeroed_page(GFP_KERNEL); + if (!page) { ret = -ENOMEM; break; } /* We don't refcnt properly, so set reserved on page. * (this allocation is permanent) */ - SetPageReserved(virt_to_page(xen_start_info.store_page)); + SetPageReserved(virt_to_page(page)); /* Initial connect. Setup channel and page. */ xen_start_info.store_evtchn = data; - ret = pfn_to_mfn(virt_to_phys((void *)xen_start_info.store_page) >> - PAGE_SHIFT); + xen_start_info.store_mfn = pfn_to_mfn(virt_to_phys((void *)page) >> + PAGE_SHIFT); + ret = xen_start_info.store_mfn; /* We'll return then this will wait for daemon to answer */ kthread_run(do_xenbus_probe, NULL, "xenbus_probe"); diff --git a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c index d402e81f53..f28fa37ee2 100644 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c @@ -202,10 +202,11 @@ int xb_init_comms(void **in, void **out) return err; } + *out = machine_to_virt(xen_start_info.store_mfn << PAGE_SHIFT); + *in = *out + PAGE_SIZE / 2; + /* FIXME zero out page -- domain builder should probably do this*/ - memset((void *)xen_start_info.store_page, 0, PAGE_SIZE); + memset(*out, 0, PAGE_SIZE); - *out = (void *)xen_start_info.store_page; - *in = (void *)xen_start_info.store_page + PAGE_SIZE/2; return 0; } diff --git a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c index 6b5735d809..407449dd64 100644 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c @@ -94,7 +94,7 @@ static void *read_reply(enum xsd_sockmsg_type *type, unsigned int *len) void xenbus_debug_write(const char *str, unsigned int count) { struct xsd_sockmsg msg; - void *out = (void *)xen_start_info.store_page; + void *out = machine_to_virt(xen_start_info.store_mfn << PAGE_SHIFT); msg.type = XS_DEBUG; msg.len = sizeof("print") + count + 1; diff --git a/tools/libxc/xc_linux_build.c b/tools/libxc/xc_linux_build.c index 27e019ca4a..b0a14c7cc5 100644 --- a/tools/libxc/xc_linux_build.c +++ b/tools/libxc/xc_linux_build.c @@ -500,6 +500,8 @@ static int setup_guest(int xc_handle, goto error_out; #endif + *store_mfn = page_array[(vstoreinfo_start-dsi.v_start) >> PAGE_SHIFT]; + start_info = xc_map_foreign_range( xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, page_array[(vstartinfo_start-dsi.v_start)>>PAGE_SHIFT]); @@ -511,7 +513,7 @@ static int setup_guest(int xc_handle, start_info->nr_pt_frames = nr_pt_pages; start_info->mfn_list = vphysmap_start; start_info->domain_controller_evtchn = control_evtchn; - start_info->store_page = vstoreinfo_start; + start_info->store_mfn = *store_mfn; start_info->store_evtchn = store_evtchn; if ( initrd_len != 0 ) { @@ -522,9 +524,6 @@ static int setup_guest(int xc_handle, start_info->cmd_line[MAX_GUEST_CMDLINE-1] = '\0'; munmap(start_info, PAGE_SIZE); - /* Tell our caller where we told domain store page was. */ - *store_mfn = page_array[((vstoreinfo_start-dsi.v_start)>>PAGE_SHIFT)]; - /* shared_info page starts its life empty. */ shared_info = xc_map_foreign_range( xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, shared_info_frame); diff --git a/xen/include/public/xen.h b/xen/include/public/xen.h index 66ffeb60aa..9255d8cb15 100644 --- a/xen/include/public/xen.h +++ b/xen/include/public/xen.h @@ -446,7 +446,7 @@ typedef struct start_info { memory_t mod_start; /* VIRTUAL address of pre-loaded module. */ memory_t mod_len; /* Size (bytes) of pre-loaded module. */ s8 cmd_line[MAX_GUEST_CMDLINE]; - memory_t store_page; /* VIRTUAL address of store page. */ + memory_t store_mfn; /* MACHINE page number of shared page. */ u16 store_evtchn; /* Event channel for store communication. */ } start_info_t; -- 2.30.2